/* 资金明细 */
<template>
  <div class="app-container">

    <el-card shadow="never" class="box-card">
      <div class="text item">
        猫粮余额：{{userData.balance}}   宠爱值余额：{{userData.petValueBalance}}    提现的宠爱值：{{userData.petValueBalance}}
      </div>
    </el-card>

    <p>
      <el-radio-group v-model="queryParams.itemType" @change="getList">
        <el-radio-button :label="1">猫粮明细</el-radio-button>
        <el-radio-button :label="2">宠爱值明细</el-radio-button>
      </el-radio-group>
    </p>

    <el-table v-if="queryParams.itemType===1" v-loading="loading" :data="userBalancePetValueDetailList">
      <el-table-column label="时间" align="center" prop="changeTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.changeTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="事项" align="center" prop="text" />
      <el-table-column label="猫粮变化" align="center" prop="amount" />
      <el-table-column label="猫粮余额" align="center" prop="currentAmount" />
    </el-table>
    <el-table v-if="queryParams.itemType===2" v-loading="loading" :data="userPetValueList">
       <el-table-column label="时间" align="center" prop="changeTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.changeTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="事项" align="center" prop="text" />
      <el-table-column label="宠爱值变化" align="center" prop="score" />
      <el-table-column label="宠爱值余额" align="center" prop="currentScore" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listUserPetValue } from "@/api/system/userPetValue";
import { listUserBalancePetValueDetail} from "@/api/system/userBalancePetValueDetail";



export default {
  data() {
    return {
      userPetValueList:[],
      userBalancePetValueDetailList:[],

      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        accountId: undefined,
        amountType: 0,
        itemType: 1,
      },
      userData:{}
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询用户登录日志列表 */
    getList() {
      this.loading = true;
      if(this.queryParams.itemType === 1){
        listUserBalancePetValueDetail(this.queryParams).then(response => {
          this.userBalancePetValueDetailList = response.rows;
          this.total = parseInt(response.total);
          this.loading = false;
        });
      }else if(this.queryParams.itemType === 2){
        listUserPetValue(this.queryParams).then(response => {
          this.userPetValueList = response.rows;
          this.total = parseInt(response.total);
          this.loading = false;
        });
      }
    },
    init(row){
      this.userData = row
      this.queryParams.accountId = row.id
      this.getList()
    }
  }
};
</script>